package com.study.blockingqueue;

import java.util.concurrent.BlockingQueue;

public class Producer implements Runnable {

//	private final BlockingQueue<Character> queue;
	private final BlockingQueue<Integer> queue;

//	public Producer(BlockingQueue<Character> q) {
//		this.queue = q;
//	}
	
	public Producer(BlockingQueue<Integer> q) {
		this.queue = q;
	}

	Character produce() {
		char c = (char) (Math.random() * 26 + 'A');

		System.out.println("生产前：" + c);

		return c;
	}

	@Override
	public void run() {
		try {
			final int length = 30;
			for (int i = 0; i < length; i++) {
//				queue.put(produce());

				queue.put(Integer.valueOf(i));

//				System.out.println("生产后：" + queue.peek());
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

	}
}